package com.fanshuai.endpoint.health.indicator;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
import org.springframework.boot.actuate.health.Health;
import org.springframework.stereotype.Component;

@Component
public class CustomHealthIndicator extends AbstractHealthIndicator {
    @Value("${custom.health}")
    private boolean health;

    @Override
    protected void doHealthCheck(Health.Builder builder) throws Exception {
        if (health) {
            builder.up().withDetail("value", true);
        } else {
            builder.down().withDetail("error", "config false");
        }
    }
}
